home *** CD-ROM | disk | FTP | other *** search
- ;-------------------------hex8out routine begins--------------------------+
- ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
- ; page : 53
- ;
- ; NAME HEX8OUT
- ; ROUTINE FOR Conversion from 8-bit Binary to ASCII Hexidecimal
- ;
- ; FUNCTION: This routine accepts a 8-bit binary number in the DL register
- ; and converts it to ASCII hexidecimal form which is sent to the std input
- ; device.
- ;
- ; INPUT: Upon entry an 8-bit binary number is in DL
- ; OUTPUT: A string of ASCII digits representing a hexidecimal number is
- ; sent out through the std output device.
- ; REGISTERS USED: No registers are modified. DL is used for input.
- ; SEGMENTS REFERENCED: None
- ; ROUTINES CALLED: STDOUT
- ; SPECIAL NOTES: None
- ;
- ; ROUTINE TO CONVERT FROM INTERNAL 8-BIT BINARY TO ASCII HEXIDECIMAL.
- ;
- hex8out proc far
- ;
- ; a binary number is in DL
- ;
- push cx ; save registers
- push ax
- ;
- mov cx,2 ; loop for a count of two
- ;
- hex8out1:
- push cx ; save the count
- mov cl,4 ; for a count of four
- rol dl,cl ; rotate DL left
- ;
- mov al,dl ; move into AL
- and al,00Fh ; just digit
- daa ; add 6 if A - F
- add al,0F0h ; bump a carry if A - F
- adc al,040h ; here is the ASCII
- call stdout ; send it
- ;
- pop cx
- loop hex8out1
- ;
- pop ax ; restore registers
- pop cx
- ret ; return
- ;
- hex8out endp
- ;-------------------------hex8out routine ends---------------------------+